<?php
$yhendus = new mysqli("localhost", "if11", "4e3HtHTXGXQC8uas", "if11_rnrz");
if(isSet($_REQUEST["lopuid"])){
	$kask=$yhendus->prepare("UPDATE voistlejad SET loppaeg=? WHERE id=?");
	$kask->bind_param("si", $_REQUEST['loppaeg'], $_REQUEST['lopuid']);
	$kask->execute();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Suusavõistlus</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="header">
	<div id="menu">
		<ul>
			<li><a href="index.html">Avaleht</a></li>
			<li><a href="Stardipunkt.php">Stardipunkt</a></li>
			<li><a href="finish.php">Finiš</a></li>
			<li><a href="statistika.php">Statistika</a></li>
			
		</ul>
	</div>
	<!-- end #menu -->
	<div id="logo">
		<h1><a href="#">Suusavõistlus </a></h1>
	</div>
	<hr />
</div>

<div id="page">
	<div id="page-bgtop">
		<div id="page-bgbtm">
			<div id="content">
				<div class="post">
					
					<h2 class="title"><a href="#">Meie suusavõistluse leht </a></h2>
					<div class="entry">
					<table>
						<th>ID</th>
						<th>Algusaeg</th>
						<th>Sisesta lõppuaeg</th>
					<?php
					$kask=$yhendus->prepare("SELECT id, algusaeg FROM voistlejad WHERE loppaeg is NULL");
					$kask->bind_result($id, $algusaeg);
					$kask->execute();
					while($kask->fetch()){
					echo "
					<tr>
					<td>".htmlspecialchars($id)."</td>
					<td>".htmlspecialchars($algusaeg)."</td>
					<td>
					<form action='finish.php'>
					<input type='hidden' name='lopuid' value='$id'>
					<input type='text' name='loppaeg'>
					<input type='submit' value='Lisa'>
					</form>
					</td>
					</tr>
					";
					}
					?>
					</table>
					</div>
					
				</div>
				
			</div>
			<!-- end #content -->
			<div id="sidebar">
				<ul>
					<li>
						
					</li>
				</ul>
			</div>
			<!-- end #sidebar -->
			<div style="clear: both;">&nbsp;</div>
		</div>
		<!-- end #page -->
	</div>
</div>
<div id="footer-bgcontent">
	<div id="footer">
		
	</div>
	<!-- end #footer -->
</div>
</body>
</html>
